package org.wisdom.ab.apis;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.wisdom.ab.dto.DepartmentDto;
import org.wisdom.annotation.WisdomFeignClient;
import org.wisdom.vo.ResponseResult;

/**
 * 部门管理API
 *
 * @author 张智研
 * @date 2022/05/16 07:59
 **/
@WisdomFeignClient(name = "${wisdom.ab.name:wisdom-ab}", path = "/${wisdom.ab.name:wisdom-ab}/department",
    contextId = "wisdom-ab-department")
public interface DepartmentController {

    /**
     * 创建部门
     *
     * @author 张智研
     * @date 2022/05/16 08:00
     * @param departmentDto
     *            部门信息
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @PostMapping
    ResponseResult<String> save(@RequestBody DepartmentDto departmentDto);

    /**
     * 获取部门信息
     *
     * @author 张智研
     * @date 2022/05/23 10:27
     * @param departmentId
     *            部门id
     * @return org.wisdom.vo.ResponseResult<org.wisdom.ab.dto.DepartmentDto>
     */
    @GetMapping("/{departmentId}")
    ResponseResult<DepartmentDto> get(@PathVariable("departmentId") String departmentId);

    /**
     * 删除部门
     *
     * @author 张智研
     * @date 2022/05/16 08:02
     * @param departmentId
     *            部门id
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @DeleteMapping("/{departmentId}")
    ResponseResult<String> delete(@PathVariable("departmentId") String departmentId);

    /**
     * 获取部门列表
     *
     * @author 张智研
     * @date 2022/05/16 08:04
     * @param companyId
     *            公司id
     * @param departmentId
     *            部门id。获取指定部门及其下的子部门（以及子部门的子部门等等，递归）。 如果不填，默认获取全量组织架构
     * @return org.wisdom.vo.ResponseResult<java.util.List<org.wisdom.ab.dto.DepartmentDto>>
     */
    @GetMapping("/list")
    ResponseResult<List<DepartmentDto>> list(@RequestParam("companyId") String companyId,
        @RequestParam(value = "departmentId", required = false, defaultValue = "") String departmentId);

    /**
     * 获取全部部门列表
     *
     * @author 张智研
     * @date 2023/05/19 14:19
     * @return org.wisdom.vo.ResponseResult<java.util.List<org.wisdom.ab.dto.DepartmentDto>>
     */
    @GetMapping("/listAll")
    ResponseResult<List<DepartmentDto>> listAll();
}
